<?php
/*
	This SQL query will create the table to store your object.

	CREATE TABLE `company` (
	`companyid` int(11) NOT NULL auto_increment,
	`name` VARCHAR(255) NOT NULL,
	`activitysectorid` int(11) NOT NULL,
	`contactid` int(11) NOT NULL, INDEX(`activitysectorid`,`contactid`), PRIMARY KEY  (`companyid`)) ENGINE=MyISAM;
*/

/**
* <b>Company</b> class with integrated CRUD methods.
* @author Php Object Generator
* @version POG 3.0f / PHP5.1 MYSQL
* @see http://www.phpobjectgenerator.com/plog/tutorials/45/pdo-mysql
* @copyright Free for personal & commercial use. (Offered under the BSD license)
* @link http://www.phpobjectgenerator.com/?language=php5.1&wrapper=pdo&pdoDriver=mysql&objectName=Company&attributeList=array+%28%0A++0+%3D%3E+%27name%27%2C%0A++1+%3D%3E+%27ActivitySector%27%2C%0A++2+%3D%3E+%27Address%27%2C%0A++3+%3D%3E+%27Contact%27%2C%0A++4+%3D%3E+%27Document%27%2C%0A++5+%3D%3E+%27GotStudentActivity%27%2C%0A++6+%3D%3E+%27GotProRole%27%2C%0A%29&typeList=array%2B%2528%250A%2B%2B0%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B1%2B%253D%253E%2B%2527BELONGSTO%2527%252C%250A%2B%2B2%2B%253D%253E%2B%2527JOIN%2527%252C%250A%2B%2B3%2B%253D%253E%2B%2527BELONGSTO%2527%252C%250A%2B%2B4%2B%253D%253E%2B%2527JOIN%2527%252C%250A%2B%2B5%2B%253D%253E%2B%2527HASMANY%2527%252C%250A%2B%2B6%2B%253D%253E%2B%2527HASMANY%2527%252C%250A%2529
*/
include_once('class.pog_base.php');
include_once('class.addresscompanymap.php');
include_once('class.companydocumentmap.php');
class Company extends POG_Base
{
	public $companyId = '';

	/**
	 * @var VARCHAR(255)
	 */
	public $name;
	
	/**
	 * @var INT(11)
	 */
	public $activitysectorId;
	
	/**
	 * @var private array of Address objects
	 */
	private $_addressList = array();
	
	/**
	 * @var INT(11)
	 */
	public $contactId;
	
	/**
	 * @var private array of Document objects
	 */
	private $_documentList = array();
	
	/**
	 * @var private array of GotStudentActivity objects
	 */
	private $_gotstudentactivityList = array();
	
	/**
	 * @var private array of GotProRole objects
	 */
	private $_gotproroleList = array();
	
	public $pog_attribute_type = array(
		"companyId" => array('db_attributes' => array("NUMERIC", "INT")),
		"name" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
		"ActivitySector" => array('db_attributes' => array("OBJECT", "BELONGSTO")),
		"Address" => array('db_attributes' => array("OBJECT", "JOIN")),
		"Contact" => array('db_attributes' => array("OBJECT", "BELONGSTO")),
		"Document" => array('db_attributes' => array("OBJECT", "JOIN")),
		"GotStudentActivity" => array('db_attributes' => array("OBJECT", "HASMANY")),
		"GotProRole" => array('db_attributes' => array("OBJECT", "HASMANY")),
		);
	public $pog_query;
	
	
	/**
	* Getter for some private attributes
	* @return mixed $attribute
	*/
	public function __get($attribute)
	{
		if (isset($this->{"_".$attribute}))
		{
			return $this->{"_".$attribute};
		}
		else
		{
			return false;
		}
	}
	
	function Company($name='')
	{
		$this->name = $name;
		$this->_addressList = array();
		$this->_documentList = array();
		$this->_gotstudentactivityList = array();
		$this->_gotproroleList = array();
	}
	
	
	/**
	* Gets object from database
	* @param integer $companyId 
	* @return object $Company
	*/
	function Get($companyId)
	{
		$connection = Database::Connect();
		$this->pog_query = "select * from `company` where `companyid`='".intval($companyId)."' LIMIT 1";
		$cursor = Database::Reader($this->pog_query, $connection);
		while ($row = Database::Read($cursor))
		{
			$this->companyId = $row['companyid'];
			$this->name = $this->Unescape($row['name']);
			$this->activitysectorId = $row['activitysectorid'];
			$this->contactId = $row['contactid'];
		}
		return $this;
	}
	
	
	/**
	* Returns a sorted array of objects that match given conditions
	* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...} 
	* @param string $sortBy 
	* @param boolean $ascending 
	* @param int limit 
	* @return array $companyList
	*/
	function GetList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
	{
		$connection = Database::Connect();
		$sqlLimit = ($limit != '' ? "LIMIT $limit" : '');
		$this->pog_query = "select * from `company` ";
		$companyList = Array();
		if (sizeof($fcv_array) > 0)
		{
			$this->pog_query .= " where ";
			for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
			{
				if (sizeof($fcv_array[$i]) == 1)
				{
					$this->pog_query .= " ".$fcv_array[$i][0]." ";
					continue;
				}
				else
				{
					if ($i > 0 && sizeof($fcv_array[$i-1]) != 1)
					{
						$this->pog_query .= " AND ";
					}
					if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
					{
						if ($GLOBALS['configuration']['db_encoding'] == 1)
						{
							$value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(".$fcv_array[$i][2].")" : "'".$fcv_array[$i][2]."'";
							$this->pog_query .= "BASE64_DECODE(`".$fcv_array[$i][0]."`) ".$fcv_array[$i][1]." ".$value;
						}
						else
						{
							$value =  POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$this->Escape($fcv_array[$i][2])."'";
							$this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
						}
					}
					else
					{
						$value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$fcv_array[$i][2]."'";
						$this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
					}
				}
			}
		}
		if ($sortBy != '')
		{
			if (isset($this->pog_attribute_type[$sortBy]['db_attributes']) && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET')
			{
				if ($GLOBALS['configuration']['db_encoding'] == 1)
				{
					$sortBy = "BASE64_DECODE($sortBy) ";
				}
				else
				{
					$sortBy = "$sortBy ";
				}
			}
			else
			{
				$sortBy = "$sortBy ";
			}
		}
		else
		{
			$sortBy = "companyid";
		}
		$this->pog_query .= " order by ".$sortBy." ".($ascending ? "asc" : "desc")." $sqlLimit";
		$thisObjectName = get_class($this);
		$cursor = Database::Reader($this->pog_query, $connection);
		while ($row = Database::Read($cursor))
		{
			$company = new $thisObjectName();
			$company->companyId = $row['companyid'];
			$company->name = $this->Unescape($row['name']);
			$company->activitysectorId = $row['activitysectorid'];
			$company->contactId = $row['contactid'];
			$companyList[] = $company;
		}
		return $companyList;
	}
	
	
	/**
	* Saves the object to the database
	* @return integer $companyId
	*/
	function Save($deep = true)
	{
		$connection = Database::Connect();
		$this->pog_query = "select `companyid` from `company` where `companyid`='".$this->companyId."' LIMIT 1";
		$rows = Database::Query($this->pog_query, $connection);
		if ($rows > 0)
		{
			$this->pog_query = "update `company` set 
			`name`='".$this->Escape($this->name)."', 
			`activitysectorid`='".$this->activitysectorId."', 
			`contactid`='".$this->contactId."'where `companyid`='".$this->companyId."'";
		}
		else
		{
			$this->pog_query = "insert into `company` (`name`, `activitysectorid`, `contactid`) values (
			'".$this->Escape($this->name)."', 
			'".$this->activitysectorId."', 
			'".$this->contactId."')";
		}
		$insertId = Database::InsertOrUpdate($this->pog_query, $connection);
		if ($this->companyId == "")
		{
			$this->companyId = $insertId;
		}
		if ($deep)
		{
			foreach ($this->_addressList as $address)
			{
				$address->Save();
				$map = new AddressCompanyMap();
				$map->AddMapping($this, $address);
			}
			foreach ($this->_documentList as $document)
			{
				$document->Save();
				$map = new CompanyDocumentMap();
				$map->AddMapping($this, $document);
			}
			foreach ($this->_gotstudentactivityList as $gotstudentactivity)
			{
				$gotstudentactivity->companyId = $this->companyId;
				$gotstudentactivity->Save($deep);
			}
			foreach ($this->_gotproroleList as $gotprorole)
			{
				$gotprorole->companyId = $this->companyId;
				$gotprorole->Save($deep);
			}
		}
		return $this->companyId;
	}
	
	
	/**
	* Clones the object and saves it to the database
	* @return integer $companyId
	*/
	function SaveNew($deep = false)
	{
		$this->companyId = '';
		return $this->Save($deep);
	}
	
	
	/**
	* Deletes the object from the database
	* @return boolean
	*/
	function Delete($deep = false, $across = false)
	{
		if ($deep)
		{
			$gotstudentactivityList = $this->GetGotstudentactivityList();
			foreach ($gotstudentactivityList as $gotstudentactivity)
			{
				$gotstudentactivity->Delete($deep, $across);
			}
			$gotproroleList = $this->GetGotproroleList();
			foreach ($gotproroleList as $gotprorole)
			{
				$gotprorole->Delete($deep, $across);
			}
		}
		if ($across)
		{
			$addressList = $this->GetAddressList();
			$map = new AddressCompanyMap();
			$map->RemoveMapping($this);
			foreach ($addressList as $address)
			{
				$address->Delete($deep, $across);
			}
			$documentList = $this->GetDocumentList();
			$map = new CompanyDocumentMap();
			$map->RemoveMapping($this);
			foreach ($documentList as $document)
			{
				$document->Delete($deep, $across);
			}
		}
		else
		{
			$map = new AddressCompanyMap();
			$map->RemoveMapping($this);
			$map = new CompanyDocumentMap();
			$map->RemoveMapping($this);
		}
		$connection = Database::Connect();
		$this->pog_query = "delete from `company` where `companyid`='".$this->companyId."'";
		return Database::NonQuery($this->pog_query, $connection);
	}
	
	
	/**
	* Deletes a list of objects that match given conditions
	* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...} 
	* @param bool $deep 
	* @return 
	*/
	function DeleteList($fcv_array, $deep = false, $across = false)
	{
		if (sizeof($fcv_array) > 0)
		{
			if ($deep || $across)
			{
				$objectList = $this->GetList($fcv_array);
				foreach ($objectList as $object)
				{
					$object->Delete($deep, $across);
				}
			}
			else
			{
				$connection = Database::Connect();
				$pog_query = "delete from `company` where ";
				for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
				{
					if (sizeof($fcv_array[$i]) == 1)
					{
						$pog_query .= " ".$fcv_array[$i][0]." ";
						continue;
					}
					else
					{
						if ($i > 0 && sizeof($fcv_array[$i-1]) !== 1)
						{
							$pog_query .= " AND ";
						}
						if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
						{
							$pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$this->Escape($fcv_array[$i][2])."'";
						}
						else
						{
							$pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$fcv_array[$i][2]."'";
						}
					}
				}
				return Database::NonQuery($pog_query, $connection);
			}
		}
	}
	
	
	/**
	* Associates the ActivitySector object to this one
	* @return boolean
	*/
	function GetActivitysector()
	{
		$activitysector = new ActivitySector();
		return $activitysector->Get($this->activitysectorId);
	}
	
	
	/**
	* Associates the ActivitySector object to this one
	* @return 
	*/
	function SetActivitysector(&$activitysector)
	{
		$this->activitysectorId = $activitysector->activitysectorId;
	}
	
	
	/**
	* Creates mappings between this and all objects in the Address List array. Any existing mapping will become orphan(s)
	* @return null
	*/
	function SetAddressList(&$addressList)
	{
		$map = new AddressCompanyMap();
		$map->RemoveMapping($this);
		$this->_addressList = $addressList;
	}
	
	
	/**
	* Returns a sorted array of objects that match given conditions
	* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...} 
	* @param string $sortBy 
	* @param boolean $ascending 
	* @param int limit 
	* @return array $companyList
	*/
	function GetAddressList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
	{
		$sqlLimit = ($limit != '' ? "LIMIT $limit" : '');
		$connection = Database::Connect();
		$address = new Address();
		$addressList = Array();
		$this->pog_query = "select distinct * from `address` a INNER JOIN `addresscompanymap` m ON m.addressid = a.addressid where m.companyid = '$this->companyId' ";
		if (sizeof($fcv_array) > 0)
		{
			$this->pog_query .= " AND ";
			for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
			{
				if (sizeof($fcv_array[$i]) == 1)
				{
					$this->pog_query .= " ".$fcv_array[$i][0]." ";
					continue;
				}
				else
				{
					if ($i > 0 && sizeof($fcv_array[$i-1]) != 1)
					{
						$this->pog_query .= " AND ";
					}
					if (isset($address->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $address->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $address->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
					{
						if ($GLOBALS['configuration']['db_encoding'] == 1)
						{
							$value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(".$fcv_array[$i][2].")" : "'".$fcv_array[$i][2]."'";
							$this->pog_query .= "BASE64_DECODE(`".$fcv_array[$i][0]."`) ".$fcv_array[$i][1]." ".$value;
						}
						else
						{
							$value =  POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$this->Escape($fcv_array[$i][2])."'";
							$this->pog_query .= "a.`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
						}
					}
					else
					{
						$value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$fcv_array[$i][2]."'";
						$this->pog_query .= "a.`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
					}
				}
			}
		}
		if ($sortBy != '')
		{
			if (isset($address->pog_attribute_type[$sortBy]['db_attributes']) && $address->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $address->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET')
			{
				if ($GLOBALS['configuration']['db_encoding'] == 1)
				{
					$sortBy = "BASE64_DECODE(a.$sortBy) ";
				}
				else
				{
					$sortBy = "a.$sortBy ";
				}
			}
			else
			{
				$sortBy = "a.$sortBy ";
			}
		}
		else
		{
			$sortBy = "a.addressid";
		}
		$this->pog_query .= " order by ".$sortBy." ".($ascending ? "asc" : "desc")." $sqlLimit";
		$cursor = Database::Reader($this->pog_query, $connection);
		while($rows = Database::Read($cursor))
		{
			$address = new Address();
			foreach ($address->pog_attribute_type as $attribute_name => $attrubute_type)
			{
				if ($attrubute_type['db_attributes'][1] != "HASMANY" && $attrubute_type['db_attributes'][1] != "JOIN")
				{
					if ($attrubute_type['db_attributes'][1] == "BELONGSTO")
					{
						$address->{strtolower($attribute_name).'Id'} = $rows[strtolower($attribute_name).'id'];
						continue;
					}
					$address->{$attribute_name} = $this->Unescape($rows[strtolower($attribute_name)]);
				}
			}
			$addressList[] = $address;
		}
		return $addressList;
	}
	
	
	/**
	* Associates the Address object to this one
	* @return 
	*/
	function AddAddress(&$address)
	{
		if ($address instanceof Address)
		{
			if (in_array($this, $address->companyList, true))
			{
				return false;
			}
			else
			{
				$found = false;
				foreach ($this->_addressList as $address2)
				{
					if ($address->addressId > 0 && $address->addressId == $address2->addressId)
					{
						$found = true;
						break;
					}
				}
				if (!$found)
				{
					$this->_addressList[] = $address;
				}
			}
		}
	}
	
	
	/**
	* Associates the Contact object to this one
	* @return boolean
	*/
	function GetContact()
	{
		$contact = new Contact();
		return $contact->Get($this->contactId);
	}
	
	
	/**
	* Associates the Contact object to this one
	* @return 
	*/
	function SetContact(&$contact)
	{
		$this->contactId = $contact->contactId;
	}
	
	
	/**
	* Creates mappings between this and all objects in the Document List array. Any existing mapping will become orphan(s)
	* @return null
	*/
	function SetDocumentList(&$documentList)
	{
		$map = new CompanyDocumentMap();
		$map->RemoveMapping($this);
		$this->_documentList = $documentList;
	}
	
	
	/**
	* Returns a sorted array of objects that match given conditions
	* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...} 
	* @param string $sortBy 
	* @param boolean $ascending 
	* @param int limit 
	* @return array $companyList
	*/
	function GetDocumentList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
	{
		$sqlLimit = ($limit != '' ? "LIMIT $limit" : '');
		$connection = Database::Connect();
		$document = new Document();
		$documentList = Array();
		$this->pog_query = "select distinct * from `document` a INNER JOIN `companydocumentmap` m ON m.documentid = a.documentid where m.companyid = '$this->companyId' ";
		if (sizeof($fcv_array) > 0)
		{
			$this->pog_query .= " AND ";
			for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
			{
				if (sizeof($fcv_array[$i]) == 1)
				{
					$this->pog_query .= " ".$fcv_array[$i][0]." ";
					continue;
				}
				else
				{
					if ($i > 0 && sizeof($fcv_array[$i-1]) != 1)
					{
						$this->pog_query .= " AND ";
					}
					if (isset($document->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $document->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $document->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
					{
						if ($GLOBALS['configuration']['db_encoding'] == 1)
						{
							$value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(".$fcv_array[$i][2].")" : "'".$fcv_array[$i][2]."'";
							$this->pog_query .= "BASE64_DECODE(`".$fcv_array[$i][0]."`) ".$fcv_array[$i][1]." ".$value;
						}
						else
						{
							$value =  POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$this->Escape($fcv_array[$i][2])."'";
							$this->pog_query .= "a.`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
						}
					}
					else
					{
						$value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$fcv_array[$i][2]."'";
						$this->pog_query .= "a.`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
					}
				}
			}
		}
		if ($sortBy != '')
		{
			if (isset($document->pog_attribute_type[$sortBy]['db_attributes']) && $document->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $document->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET')
			{
				if ($GLOBALS['configuration']['db_encoding'] == 1)
				{
					$sortBy = "BASE64_DECODE(a.$sortBy) ";
				}
				else
				{
					$sortBy = "a.$sortBy ";
				}
			}
			else
			{
				$sortBy = "a.$sortBy ";
			}
		}
		else
		{
			$sortBy = "a.documentid";
		}
		$this->pog_query .= " order by ".$sortBy." ".($ascending ? "asc" : "desc")." $sqlLimit";
		$cursor = Database::Reader($this->pog_query, $connection);
		while($rows = Database::Read($cursor))
		{
			$document = new Document();
			foreach ($document->pog_attribute_type as $attribute_name => $attrubute_type)
			{
				if ($attrubute_type['db_attributes'][1] != "HASMANY" && $attrubute_type['db_attributes'][1] != "JOIN")
				{
					if ($attrubute_type['db_attributes'][1] == "BELONGSTO")
					{
						$document->{strtolower($attribute_name).'Id'} = $rows[strtolower($attribute_name).'id'];
						continue;
					}
					$document->{$attribute_name} = $this->Unescape($rows[strtolower($attribute_name)]);
				}
			}
			$documentList[] = $document;
		}
		return $documentList;
	}
	
	
	/**
	* Associates the Document object to this one
	* @return 
	*/
	function AddDocument(&$document)
	{
		if ($document instanceof Document)
		{
			if (in_array($this, $document->companyList, true))
			{
				return false;
			}
			else
			{
				$found = false;
				foreach ($this->_documentList as $document2)
				{
					if ($document->documentId > 0 && $document->documentId == $document2->documentId)
					{
						$found = true;
						break;
					}
				}
				if (!$found)
				{
					$this->_documentList[] = $document;
				}
			}
		}
	}
	
	
	/**
	* Gets a list of GotStudentActivity objects associated to this one
	* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...} 
	* @param string $sortBy 
	* @param boolean $ascending 
	* @param int limit 
	* @return array of GotStudentActivity objects
	*/
	function GetGotstudentactivityList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
	{
		$gotstudentactivity = new GotStudentActivity();
		$fcv_array[] = array("companyId", "=", $this->companyId);
		$dbObjects = $gotstudentactivity->GetList($fcv_array, $sortBy, $ascending, $limit);
		return $dbObjects;
	}
	
	
	/**
	* Makes this the parent of all GotStudentActivity objects in the GotStudentActivity List array. Any existing GotStudentActivity will become orphan(s)
	* @return null
	*/
	function SetGotstudentactivityList(&$list)
	{
		$this->_gotstudentactivityList = array();
		$existingGotstudentactivityList = $this->GetGotstudentactivityList();
		foreach ($existingGotstudentactivityList as $gotstudentactivity)
		{
			$gotstudentactivity->companyId = '';
			$gotstudentactivity->Save(false);
		}
		$this->_gotstudentactivityList = $list;
	}
	
	
	/**
	* Associates the GotStudentActivity object to this one
	* @return 
	*/
	function AddGotstudentactivity(&$gotstudentactivity)
	{
		$gotstudentactivity->companyId = $this->companyId;
		$found = false;
		foreach($this->_gotstudentactivityList as $gotstudentactivity2)
		{
			if ($gotstudentactivity->gotstudentactivityId > 0 && $gotstudentactivity->gotstudentactivityId == $gotstudentactivity2->gotstudentactivityId)
			{
				$found = true;
				break;
			}
		}
		if (!$found)
		{
			$this->_gotstudentactivityList[] = $gotstudentactivity;
		}
	}
	
	
	/**
	* Gets a list of GotProRole objects associated to this one
	* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...} 
	* @param string $sortBy 
	* @param boolean $ascending 
	* @param int limit 
	* @return array of GotProRole objects
	*/
	function GetGotproroleList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
	{
		$gotprorole = new GotProRole();
		$fcv_array[] = array("companyId", "=", $this->companyId);
		$dbObjects = $gotprorole->GetList($fcv_array, $sortBy, $ascending, $limit);
		return $dbObjects;
	}
	
	
	/**
	* Makes this the parent of all GotProRole objects in the GotProRole List array. Any existing GotProRole will become orphan(s)
	* @return null
	*/
	function SetGotproroleList(&$list)
	{
		$this->_gotproroleList = array();
		$existingGotproroleList = $this->GetGotproroleList();
		foreach ($existingGotproroleList as $gotprorole)
		{
			$gotprorole->companyId = '';
			$gotprorole->Save(false);
		}
		$this->_gotproroleList = $list;
	}
	
	
	/**
	* Associates the GotProRole object to this one
	* @return 
	*/
	function AddGotprorole(&$gotprorole)
	{
		$gotprorole->companyId = $this->companyId;
		$found = false;
		foreach($this->_gotproroleList as $gotprorole2)
		{
			if ($gotprorole->gotproroleId > 0 && $gotprorole->gotproroleId == $gotprorole2->gotproroleId)
			{
				$found = true;
				break;
			}
		}
		if (!$found)
		{
			$this->_gotproroleList[] = $gotprorole;
		}
	}
}
?>